namespace PrjAssess.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class InitialCreate : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "dbo.MaterialBuryItems",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        PrjId = c.String(nullable: false),
                        ContentName = c.String(nullable: false),
                        Method = c.String(nullable: false),
                        Number = c.Int(nullable: false),
                        MaterialPrice = c.Double(nullable: false),
                        BuryPrice = c.Double(nullable: false),
                        Para = c.Double(nullable: false),
                        Note = c.String(),
                        Project_Id = c.Int(),
                        ContentItem_Id = c.Int(),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.Projects", t => t.Project_Id)
                .ForeignKey("dbo.ContentItems", t => t.ContentItem_Id)
                .Index(t => t.Project_Id)
                .Index(t => t.ContentItem_Id);
            
            CreateTable(
                "dbo.Projects",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        AssessDate = c.DateTime(nullable: false),
                        PrjId = c.String(nullable: false),
                        PrjName = c.String(nullable: false),
                        Contract = c.Double(nullable: false),
                        Address = c.String(nullable: false),
                        Manager = c.String(nullable: false),
                        Leader = c.String(nullable: false),
                        Manufacture = c.String(nullable: false),
                        MonitorType = c.String(nullable: false),
                        SurveyNo = c.Double(nullable: false),
                        MaterialBurySum = c.Double(nullable: false),
                        MaterialSum = c.Double(nullable: false),
                        BurySum = c.Double(nullable: false),
                        WorkSum = c.Double(nullable: false),
                        ConstructionPeriod = c.Int(nullable: false),
                        Note = c.String(),
                        FromExcel = c.Boolean(),
                        Discriminator = c.String(nullable: false, maxLength: 128),
                        PrjExtent_Id = c.Int(),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.ProjectExtents", t => t.PrjExtent_Id)
                .Index(t => t.PrjExtent_Id);
            
            CreateTable(
                "dbo.ProjectExtents",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        PrjId = c.String(nullable: false),
                        SupportNo = c.Int(nullable: false),
                        EnviComplicate = c.Double(nullable: false),
                        OperateMethod = c.Double(nullable: false),
                        RegionRatio = c.Double(nullable: false),
                        ComplicateRatio = c.Double(nullable: false),
                        SurveyTypeRatio = c.Double(nullable: false),
                        TeamRatio = c.Double(nullable: false),
                        ScaleRatio = c.Double(nullable: false),
                        MaterialPurchaseRatio = c.Double(nullable: false),
                        Note = c.String(),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.WorkItems",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        PrjId = c.String(nullable: false),
                        ContentName = c.String(nullable: false),
                        Number = c.Double(nullable: false),
                        Price = c.Double(nullable: false),
                        PriceTotal = c.Double(nullable: false),
                        PredictNo = c.Double(nullable: false),
                        Sum = c.Double(nullable: false),
                        Note = c.String(),
                        Project_Id = c.Int(),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.Projects", t => t.Project_Id)
                .Index(t => t.Project_Id);
            
            CreateTable(
                "dbo.ContentItems",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        ContentName = c.String(),
                        Note = c.String(),
                        Project_Id = c.Int(),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.Projects", t => t.Project_Id)
                .Index(t => t.Project_Id);
            
            CreateTable(
                "dbo.Users",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        UserCode = c.String(nullable: false),
                        UserPwd = c.String(nullable: false),
                        UserName = c.String(nullable: false),
                        UserType = c.Int(nullable: false),
                        Note = c.String(),
                    })
                .PrimaryKey(t => t.Id);
            
        }
        
        public override void Down()
        {
            DropIndex("dbo.ContentItems", new[] { "Project_Id" });
            DropIndex("dbo.WorkItems", new[] { "Project_Id" });
            DropIndex("dbo.Projects", new[] { "PrjExtent_Id" });
            DropIndex("dbo.MaterialBuryItems", new[] { "ContentItem_Id" });
            DropIndex("dbo.MaterialBuryItems", new[] { "Project_Id" });
            DropForeignKey("dbo.ContentItems", "Project_Id", "dbo.Projects");
            DropForeignKey("dbo.WorkItems", "Project_Id", "dbo.Projects");
            DropForeignKey("dbo.Projects", "PrjExtent_Id", "dbo.ProjectExtents");
            DropForeignKey("dbo.MaterialBuryItems", "ContentItem_Id", "dbo.ContentItems");
            DropForeignKey("dbo.MaterialBuryItems", "Project_Id", "dbo.Projects");
            DropTable("dbo.Users");
            DropTable("dbo.ContentItems");
            DropTable("dbo.WorkItems");
            DropTable("dbo.ProjectExtents");
            DropTable("dbo.Projects");
            DropTable("dbo.MaterialBuryItems");
        }
    }
}
